*------------------------------------------------------------------------------*
*------------------------------------------------------------------------------*
*------------------------------------------------------------------------------*

* Authors: Ranjit Lall & David Vilalta

* Paper: Varieties of Anxieties: Disaggregating Emotion and Voting Behavior in the COVID-19 Era

* What for: Replicates Tables and Figures For Survey Experimental Section

*------------------------------------------------------------------------------*
*------------------------------------------------------------------------------*
*------------------------------------------------------------------------------*


clear all 

* Insert folder path
global folder ".../Insert folder path"

cd "${folder}"

*Local folders
global dta "Final_data/"
global tables "Results/Tables/"
global figures "Results/Figures/"

use ${dta}Finaldata_survey, clear

global demo age female white i.education
global party pp psoe vox podemos
global covid infection


********************************************************************************
* TABLE 1
********************************************************************************


* PANEL A

logit vote_pl health_tr if condition=="Control" | condition=="Health"

logit vote_pl health_tr $demo if condition=="Control" | condition=="Health"

logit vote_pl health_tr $demo $party if condition=="Control" | condition=="Health"

logit vote_pl health_tr $demo $party $covid if condition=="Control" | condition=="Health"

logit vote_pl health_tr $demo $party $covid

* PANEL B

logit vote_al econ_tr if condition=="Control" | condition=="Economy"

logit vote_al econ_tr $demo if condition=="Control" | condition=="Economy"

logit vote_al econ_tr $demo $party if condition=="Control" | condition=="Economy"

logit vote_al econ_tr $demo $party $covid if condition=="Control" | condition=="Economy"

logit vote_al econ_tr $demo $party $covid


* PANEL C

reg health_anxiety health_tr if condition=="Control" | condition=="Health"

reg health_anxiety health_tr $demo if condition=="Control" | condition=="Health"

reg health_anxiety health_tr $demo $party if condition=="Control" | condition=="Health"

reg health_anxiety health_tr $demo $party $covid if condition=="Control" | condition=="Health"

reg health_anxiety health_tr $demo $party $covid

reg health_anxiety health_tr $demo $party $covid if duration>180 & condition=="Control" | condition=="Health"

		

* PANEL D

reg econ_anxiety econ_tr if condition=="Control" | condition=="Economy"

reg econ_anxiety econ_tr $demo if condition=="Control" | condition=="Economy"

reg econ_anxiety econ_tr $demo $party if condition=="Control" | condition=="Economy"

reg econ_anxiety econ_tr $demo $party $covid if condition=="Control" | condition=="Economy"

reg econ_anxiety econ_tr $demo $party $covid 


********************************************************************************
* FIGURE 4
********************************************************************************
		
global demo age female white 
global party pp psoe vox podemos
global covid infection

preserve

keep if condition=="Control" | condition=="Health"

* TOP LEFT
reg vote_pl c.health_tr##c.age $demo $party educ_1 educ_2 educ_3 educ_4 educ_5 educ_6 educ_7 $covid
margins, dydx(health_tr) at(age=(20 40 60 80))
marginsplot, plotopts(color(ltblue) mcolor(blue)) ///
			 ciopts(lcolor(blue) lwidth(medthick)) ///
			 yline(0, lcolor(red) lpattern(dash))  ///
			 graphregion(color(white)) ///
			 title("") ///
			 ytitle("Marginal Effect of Health Prime on Preference" "for Pro-Lockdown Candidate") ///
			 xtitle(Moderator: Elderly Share)

* TOP RIGHT
reg vote_pl c.health_tr##c.underlying $demo $party educ_1 educ_2 educ_3 educ_4 educ_5 educ_6 educ_7 $covid
margins, dydx(health_tr) at(underlying=(0 0.2 0.4 0.6 0.8 1))
marginsplot, plotopts(color(ltblue) mcolor(blue)) ///
			 ciopts(lcolor(blue) lwidth(medthick)) ///
			 graphregion(color(white)) ///
			 title("") ///
			 ytitle("Marginal Effect of Health Prime on Preference" "for Pro-Lockdown Candidate") ///
			 xtitle(Moderator: Underlying Health Issue)

restore

preserve

keep if condition=="Control" | condition=="Economy"

* BOTTOM LEFT
reg vote_al c.econ_tr##c.poor_rich $demo $party educ_1 educ_2 educ_3 educ_4 educ_5 educ_6 educ_7 $covid
margins, dydx(econ_tr) at(poor_rich=(0 1))
marginsplot, plotopts(color(ltblue) mcolor(blue)) ///
			 ciopts(lcolor(blue) lwidth(medthick)) ///
			 graphregion(color(white)) ///
			 title("") ///
			 ytitle("Marginal Effect of Economy Prime on Preference" "for Anti-Lockdown Candidate") ///
			 xtitle(Moderator: Poor / Rich)


* BOTTOM RIGHT
reg vote_al c.econ_tr##c.primary_tertiary $demo $party $covid
margins, dydx(econ_tr) at(primary_tertiary=(0 1))
marginsplot, plotopts(color(ltblue) mcolor(blue)) ///
			 ciopts(lcolor(blue) lwidth(medthick)) ///
			 yline(0, lcolor(red) lpattern(dash))  ///
			 graphregion(color(white)) ///
			 title("") ///
			 ytitle("Marginal Effect of Economy Prime on Preference" "for Anti-Lockdown Candidate") ///
			 xtitle(Moderator: Primary / Tertiary Education)

restore


********************************************************************************
* TABLE A8
********************************************************************************

* PANEL A

reg vote_pl health_tr if condition=="Control" | condition=="Health"

reg vote_pl health_tr $demo if condition=="Control" | condition=="Health"

reg vote_pl health_tr $demo $party if condition=="Control" | condition=="Health"

reg vote_pl health_tr $demo $party $covid if condition=="Control" | condition=="Health"

reg vote_pl health_tr $demo $party $covid

* PANEL B

reg vote_al econ_tr if condition=="Control" | condition=="Economy"

reg vote_al econ_tr $demo if condition=="Control" | condition=="Economy"

reg vote_al econ_tr $demo $party if condition=="Control" | condition=="Economy"

reg vote_al econ_tr $demo $party $covid if condition=="Control" | condition=="Economy"

reg vote_al econ_tr $demo $party $covid

********************************************************************************
* TABLE A9
********************************************************************************

logit vote_pl 1.health_tr $demo $party $covid if duration>180 & condition=="Control" | condition=="Health"

logit vote_pl health_tr##c.age $demo $party $covid if duration>180 & condition=="Control" | condition=="Health"

logit vote_pl health_tr##c.underlying $demo $party $covid if duration>180 & condition=="Control" | condition=="Health"

logit vote_al 1.econ_tr $demo $party $covid if duration>180 & condition=="Control" | condition=="Economy"

reg health_anxiety health_tr $demo $party $covid if duration>180 & condition=="Control" | condition=="Health"

logit vote_al econ_tr##c.poor_rich $demo $party $covid if duration>180 & condition=="Control" | condition=="Economy"

logit vote_al econ_tr##c.primary_tertiary $demo $party $covid if duration>180 & condition=="Control" | condition=="Economy"


********************************************************************************
* TABLE A10
********************************************************************************
		
* PANEL A - TOP (AGE)

logit vote_pl health_tr##c.age if condition=="Control" | condition=="Health"

logit vote_pl health_tr##c.age $demo if condition=="Control" | condition=="Health"

logit vote_pl health_tr##c.age $demo $party if condition=="Control" | condition=="Health"

logit vote_pl health_tr##c.age $demo $party $covid if condition=="Control" | condition=="Health"

logit vote_pl health_tr##c.age $demo $party $covid

* PANEL B - BOTTOM (UNDERLYING HEALTH CONDITION)

logit vote_pl health_tr##c.underlying if condition=="Control" | condition=="Health"

logit vote_pl health_tr##c.underlying $demo if condition=="Control" | condition=="Health"

logit vote_pl health_tr##c.underlying $demo $party if condition=="Control" | condition=="Health"

logit vote_pl health_tr##c.underlying $demo $party $covid if condition=="Control" | condition=="Health"

logit vote_pl health_tr##c.underlying $demo $party $covid

* PANEL B - TOP (EDUCATION)

logit vote_al econ_tr##c.primary_tertiary if condition=="Control" | condition=="Economy"

logit vote_al econ_tr##c.primary_tertiary $demo if condition=="Control" | condition=="Economy"

logit vote_al econ_tr##c.primary_tertiary $demo $party if condition=="Control" | condition=="Economy"

logit vote_al econ_tr##c.primary_tertiary $demo $party $covid if condition=="Control" | condition=="Economy"

logit vote_al econ_tr##c.primary_tertiary $demo $party $covid

* PANEL B - BOTTOM (RICH/POOR)

logit vote_al econ_tr##c.poor_rich if condition=="Control" | condition=="Economy"

logit vote_al econ_tr##c.poor_rich $demo if condition=="Control" | condition=="Economy"

logit vote_al econ_tr##c.poor_rich $demo $party if condition=="Control" | condition=="Economy"

logit vote_al econ_tr##c.poor_rich $demo $party $covid if condition=="Control" | condition=="Economy"

logit vote_al econ_tr##c.poor_rich $demo $party $covid


********************************************************************************
* TABLE A11
********************************************************************************

reg econ_anxiety econ_tr $demo $party $covid if condition=="Control" | condition=="Economy"

reg econ_anxiety health_tr $demo $party $covid if condition=="Control" | condition=="Health"

reg health_anxiety econ_tr $demo $party $covid if condition=="Control" | condition=="Economy"

reg health_anxiety health_tr $demo $party $covid if condition=="Control" | condition=="Health"
